
// create fonts
surface.CreateFont( "Arial", 14, 200, true, false, "MuseX" );

// get the materials we're going to use
local matPattern = Material( "musex/skins/Default/hash" );
local matGradient = Material( "gui/gradient" );


/*------------------------------------
	called when the skin is applied
------------------------------------*/
function SKIN:Apply( panel )

	// change the control buttons
	MuseX.CallSkinHook( "ControlsPlay", "musex/skins/Default/play" );
	MuseX.CallSkinHook( "ControlsNext", "musex/skins/Default/next" );
	MuseX.CallSkinHook( "ControlsPrevious", "musex/skins/Default/previous" );
	MuseX.CallSkinHook( "ControlsStop", "musex/skins/Default/stop" );
	MuseX.CallSkinHook( "ControlsMute", "musex/skins/Default/mute" );
	MuseX.CallSkinHook( "ControlsRepeat", "musex/skins/Default/repeat" );
	MuseX.CallSkinHook( "ControlsShuffle", "musex/skins/Default/shuffle" );
	
	// change the playlist buttons
	MuseX.CallSkinHook( "PlaylistAdd", "musex/skins/Default/add" );
	MuseX.CallSkinHook( "PlaylistRemove", "musex/skins/Default/remove" );

end


/*------------------------------------
	paint the main frame
------------------------------------*/
function SKIN:PaintMXMainFrame( panel )

	// get width and height
	local w, h = panel:GetSize();
	
	// draw blue border
	surface.SetDrawColor( 0, 184, 253, 255 );
	surface.DrawRect( 0, 0, w, h );
	
	// draw dark grey area
	surface.SetDrawColor( 41, 45, 47, 255 );
	surface.DrawRect( 0, 2, w, h - 4 );
	
	// draw light grey title bar
	surface.SetDrawColor( 61, 63, 66, 255 );
	surface.DrawRect( 0, 2, w, 20 );
	
	// draw black top line
	surface.SetDrawColor( 0, 0, 0, 255 );
	surface.DrawLine( 0, 21, w, 21 );
	
	// draw grey lines
	surface.SetDrawColor( 61, 63, 66, 255 );
	surface.DrawLine( 0, 22, w, 22 );
	surface.DrawLine( 0, 22, 0, h -4 );
	surface.DrawLine( w - 1, 22, w - 1, h -4 );
	surface.DrawLine( 0, h - 4, w, h - 4 );
	
	// draw the gradient overlay
	surface.SetMaterial( matGradient );
	surface.SetDrawColor( 0, 0, 0, 100 );
	surface.DrawTexturedRectRotated( w * 0.5, h * 0.5, w, h, 180 );

end


/*------------------------------------
	scheme the main frame
------------------------------------*/
function SKIN:SchemeMXFrame( panel )

	// change the title font & font color
	panel.lblTitle:SetTextColor( Color( 255, 255, 255, 255 ) );
	panel.lblTitle:SetFont( "MuseX" );
	
	// set the system button colors
	panel.btnClose:SetTextColor( Color( 255, 255, 255, 255 ) );
	if ( panel.Minimize ) then panel.Minimize:SetTextColor( Color( 255, 255, 255, 255 ) ); end
	if ( panel.ViewMode ) then panel.ViewMode:SetTextColor( Color( 255, 255, 255, 255 ) ); end
	
end


/*------------------------------------
	paint the slider
------------------------------------*/
function SKIN:PaintMXSlider( panel )

	// get width and height
	local w, h = panel:GetSize();
	
	// draw the blue line
	surface.SetDrawColor( 0, 184, 253, 255 );
	surface.DrawLine( 3, ( h/2 ) - 1, w - 6, ( h/2 ) - 1 );
	
	// draw the black line
	surface.SetDrawColor( 0, 0, 0, 255 );
	surface.DrawLine( 3, ( h/2 ), w - 6, ( h/2 ) );
	
	// draw the grey line
	surface.SetDrawColor( 61, 63, 66, 255 );
	surface.DrawLine( 3, ( h/2 ) + 1, w - 6, ( h/2 ) + 1 );
	
end



/*------------------------------------
	paint the listview
------------------------------------*/
function SKIN:PaintMXListView( panel )

	// get width and height
	local w, h = panel:GetSize();
	
	// pattern block size
	local size = 32;
	
	// set the pattern material & color
	surface.SetMaterial( matPattern );
	surface.SetDrawColor( 80, 80, 80, 100 );
	
	// move from left to right
	for i = 0, w, size do
	
		// top to bottom
		for j = 0, h, size do
		
			// draw texture
			surface.DrawTexturedRect( i, j, size, size );
		
		end
	
	end
	
	// draw gradient overlay
	surface.SetMaterial( matGradient );
	surface.SetDrawColor( 0, 0, 0, 180 );
	surface.DrawTexturedRectRotated( w * 0.5, h * 0.5, w, h, 180 );
	
	// shrink width & height
	w = w - 1;
	h = h - 1;
	
	// draw black outline
	surface.SetDrawColor( 0, 0, 0, 255 );
	surface.DrawLine( 0, 0, w, 0 );
	surface.DrawLine( w, 0, w, h );
	surface.DrawLine( w, h, 0, h );
	surface.DrawLine( 0, h, 0, 0 );

end


/*------------------------------------
	paint the listview header
------------------------------------*/
function SKIN:PaintMXListViewHeader( panel )

	// get width and height
	local w, h = panel:GetSize();
	
	// check if background painting is enabled
	if ( panel.m_bBackground ) then
	
		// set the standard colors
		local col1 = Color( 60, 60, 60, 255 );
		local col2 = Color( 0, 0, 0, 255 );
		
		// lighten out if disabled
		if ( panel:GetDisabled() ) then
		
			col1 = Color( 100, 100, 100, 255 );
			
		// darken if pressed or selected
		elseif ( panel.Depressed || panel:GetSelected() ) then
		
			col1 = Color( 40, 40, 40, 255 );
			col2 = Color( 0, 0, 0, 255 );
			
		//  lighten if hovered
		elseif ( panel.Hovered ) then
		
			col1 = Color( 80, 80, 80, 255 );
			
		end
		
		// draw the background
		surface.SetDrawColor( col1.r, col1.g, col1.b, col1.a );
		panel:DrawFilledRect();
		
		// shrink width and height
		w = w - 1;
		h = h - 1;
		
		// draw the outline border
		surface.SetDrawColor( col2.r, col2.g, col2.b, col2.a );
		surface.DrawLine( 0, 0, w, 0 );
		surface.DrawLine( w, 0, w, h );
		surface.DrawLine( w, h, 0, h );
		surface.DrawLine( 0, h, 0, 0 );
	
	end

end


/*------------------------------------
	scheme the listview header
------------------------------------*/
function SKIN:SchemeMXListViewHeader( panel )

	// set the font
	panel:SetFont( "MuseX" );

end


/*------------------------------------
	paint the listview line
------------------------------------*/
function SKIN:PaintMXListViewLine( panel )

	// check if this line is the current song
	if ( panel.Filename == MuseX.CurrentSong ) then
	
		// white
		surface.SetDrawColor( 255, 255, 255, 100 );
		
		// get width and height
		local w, h = panel:GetSize();
		
		// shrink
		w = w - 1;
		h = h - 1;
		
		// draw outline
		surface.DrawLine( 0, 0, w, 0 );
		surface.DrawLine( w, 0, w, h );
		surface.DrawLine( w, h, 0, h );
		surface.DrawLine( 0, h, 0, 0 );
		
	end
	
	// color variable
	local col = nil;
	
	// blue if selected
	if ( panel:IsSelected() ) then
	
		col = Color( 0, 184, 253, 100 );
		
	// grey if hovered
	elseif ( panel.Hovered ) then
	
		col = Color( 100, 100, 100, 100 );
		
	// alternating color
	elseif ( panel.m_bAlt ) then
	
		col = Color( 0, 0, 0, 100 );
		
	else
	
		// nothing to draw
		return;
				
	end
	
	// draw the background
	surface.SetDrawColor( col.r, col.g, col.b, col.a );
	surface.DrawRect( 0, 0, panel:GetWide(), panel:GetTall() );
	
end


/*------------------------------------
	scheme the listview line
------------------------------------*/
function SKIN:SchemeMXListViewLine( panel )

	// white font color
	panel:SetTextColor( Color( 255, 255, 255, 255 ) );
	
	// set the font
	panel:SetFont( "MuseX" );

end


/*------------------------------------
	paint button
------------------------------------*/
function SKIN:PaintMXButton( panel )

	// get width & height
	local w, h = panel:GetSize();
	
	// check if background is enabled
	if ( panel.m_bBackground ) then
	
		// set the default colors
		local col1 = Color( 60, 60, 60, 255 );
		local col2 = Color( 0, 184, 253, 255 );
		local col3 = Color( 0, 0, 0, 255 );
		
		// grey if disabled
		if ( panel:GetDisabled() ) then
		
			col1 = Color( 100, 100, 100, 255 );
			
		// swap colors if pressed or selected
		elseif ( panel.Depressed || panel:GetSelected() ) then
		
			col1 = Color( 0, 0, 0, 255 );	
			col3 = Color( 0, 184, 253, 255 );
			col2 = Color( 0, 0, 0, 255 );
		
		// darken if hovered
		elseif ( panel.Hovered ) then
		
			col1 = Color( 40, 40, 40, 255 );
			
		end
		
		// draw the background
		surface.SetDrawColor( col1.r, col1.g, col1.b, col1.a );
		panel:DrawFilledRect();
		
		// shrink
		w = w - 1;
		h = h - 1;
		
		// draw the border
		surface.SetDrawColor( col2.r, col2.g, col2.b, col2.a );
		surface.DrawLine( 0, 0, w, 0 );
		surface.DrawLine( w, 0, w, h );
		surface.DrawLine( w, h, 0, h );
		surface.DrawLine( 0, h, 0, 0 );
		
		// shrink again
		w = w - 2;
		h = h - 2;
		
		// draw inner border
		surface.SetDrawColor( col3.r, col3.g, col3.b, col3.a );
		surface.DrawLine( 1, 1, w, 1 );
		surface.DrawLine( w, 1, w, h );
		surface.DrawLine( w, h, 1, h );
		surface.DrawLine( 1, h, 1, 1 );
	
	end

end


/*------------------------------------
	paint over button
------------------------------------*/
function SKIN:PaintOverMXButton( panel )

	// badger, badger, bagder
	
end


/*------------------------------------
	scheme button
------------------------------------*/
function SKIN:SchemeMXButton( panel )

	// set the font
	panel:SetFont( "MuseX" );

end


/*------------------------------------
	paint the controls area
------------------------------------*/
function SKIN:PaintMXControls( panel )

	// mushroom, MUSHROOM!
	
end


/*------------------------------------
	paint combobox
------------------------------------*/
function SKIN:PaintMXComboBox( panel )

	// get width & height
	local w, h = panel:GetSize();
	
	// draw light background color
	surface.SetDrawColor( 180, 180, 180, 255 );
	panel:DrawFilledRect();
	
	// draw gradient overlay
	surface.SetMaterial( matGradient );
	surface.SetDrawColor( 0, 0, 0, 100 );
	surface.DrawTexturedRectRotated( w * 0.5, h * 0.5, w, h, 180 );
	
	// draw black border
	surface.SetDrawColor( 0, 0, 0, 255 );
	panel:DrawOutlinedRect();
	
end


/*------------------------------------
	paint combobox item
------------------------------------*/
function SKIN:PaintMXComboBoxItem( panel )

	// check if selected
	if ( panel:GetSelected() ) then
	
		// draw blue background
		surface.SetDrawColor( 0, 184, 253, 255 );
		panel:DrawFilledRect();
		
	end

end


/*------------------------------------
	scheme combobox item
------------------------------------*/
function SKIN:SchemeMXComboBoxItem( panel )

	// white font color
	panel:SetTextColor( Color( 0, 0, 0, 255 ) );
	
	// set the font
	panel:SetFont( "MuseX" );
	
end


/*------------------------------------
	paint text entry
------------------------------------*/
function SKIN:PaintMXTextEntry( panel )

	// check if background painting is on
	if ( panel.m_bBackground ) then
	
		// get sizes
		local w, h = panel:GetSize();
		
		// pattern block size
		local size = 32;
		
		// set material and color
		surface.SetMaterial( matPattern );
		surface.SetDrawColor( 80, 80, 80, 100 );
		
		// draw from left to right
		for i = 0, w, size do
		
			// top to bottom
			for j = 0, h, size do
			
				// draw pattern
				surface.DrawTexturedRect( i, j, size, size );
			
			end
		
		end
	
	end
	
	// draw the default text entry shit
	panel:DrawTextEntryText( Color( 255, 255, 255, 255), Color( 0, 184, 253, 255 ), Color( 0, 184, 253, 255 ) );
	
	// check if border is enabled
	if ( panel.m_bBorder ) then
	
		// draw border
		surface.SetDrawColor( 0, 0, 0, 255 );
		surface.DrawOutlinedRect( 0, 0, panel:GetWide(), panel:GetTall() );
	
	end
	
end


/*------------------------------------
	scheme text entry
------------------------------------*/
function SKIN:SchemeMXTextEntry( panel )

	// change text
	panel:SetFont( "MuseX" );

end


/*------------------------------------
	scheme label
------------------------------------*/
function SKIN:SchemeMXLabel( panel )

	// blue font color
	panel:SetTextColor( Color( 0, 184, 253, 255 ) );
	
	// set the font
	panel:SetFont( "MuseX" );

end


/*------------------------------------
	paint the compact frame
------------------------------------*/
function SKIN:PaintMXCompactFrame( panel )

	// get width and height
	local w, h = panel:GetSize();
	
	// draw blue border
	surface.SetDrawColor( 0, 184, 253, 255 );
	surface.DrawRect( 0, 0, w, h );
	
	// draw dark grey area
	surface.SetDrawColor( 41, 45, 47, 255 );
	surface.DrawRect( 0, 2, w, h - 4 );
	
	// draw light grey title bar
	surface.SetDrawColor( 61, 63, 66, 255 );
	surface.DrawRect( 0, 2, w, 20 );
	
	// draw black top line
	surface.SetDrawColor( 0, 0, 0, 255 );
	surface.DrawLine( 0, 21, w, 21 );
	
	// draw grey lines
	surface.SetDrawColor( 61, 63, 66, 255 );
	surface.DrawLine( 0, 22, w, 22 );
	surface.DrawLine( 0, 22, 0, h -4 );
	surface.DrawLine( w - 1, 22, w - 1, h -4 );
	surface.DrawLine( 0, h - 4, w, h - 4 );
	
	// pattern block size
	local size = 32;
	
	// set material and color
	surface.SetMaterial( matPattern );
	surface.SetDrawColor( 80, 80, 80, 100 );
	
	// draw from left to right
	for i = 0, w, size do
	
		// top to bottom
		for j = 0, h, size do
		
			// draw pattern
			surface.DrawTexturedRect( i, j, size, size );
		
		end
	
	end
	
	// draw the gradient overlay
	surface.SetMaterial( matGradient );
	surface.SetDrawColor( 0, 0, 0, 100 );
	surface.DrawTexturedRectRotated( w * 0.5, h * 0.5, w, h, 180 );

end


/*------------------------------------
	scheme the compact frame
------------------------------------*/
function SKIN:SchemeMXCompactFrame( panel )

	// change the title font & font color
	panel.lblTitle:SetTextColor( Color( 255, 255, 255, 255 ) );
	panel.lblTitle:SetFont( "MuseX" );
	
	// set the system button colors
	panel.btnClose:SetTextColor( Color( 255, 255, 255, 255 ) );
	panel.Minimize:SetTextColor( Color( 255, 255, 255, 255 ) );
	panel.ViewMode:SetTextColor( Color( 255, 255, 255, 255 ) );
	
end



// define
MuseX.DefineSkin( "MuseX", SKIN );
